
** Import raw data
infile using "$rawpath\NLSY79_week_employment_status\NLSY79_week_employment_status.dct", clear

** To get labels
run "$rawpath\NLSY79_week_employment_status\NLSY79_week_employment_status-value-labels.do"

tolower


rename r0000100 mom_pid
rename r0173600 sample_id_1979 
*rename r0214700 race 
rename r0214800 sex


*keep women only
keep if sex == 2
*drop military sample -- keep black/poor oversample for now
*drop if sample_id_1979 > 15
*line below kills the supplemental sample
*drop if sample_id_1979 > 8

** Labor force status before 1978
replace w0061200=. if w0061200<0
rename w0061200 status_work_before1978


** Rename week worked variables in friendly format week X of year YYYY, from 1978 to 2017


desc  w0061300 - w1377300, varlist

local week = 0
local year0 = 1978
foreach var in `r(varlist)' {

	replace `var'=. if `var'<0
	
	local varlabel : variable label `var'
	local year = substr("`varlabel'",21,4)
	if `year'==`year0' {
		local ++week
		rename `var' status_work_`year'_`week'
		local year0 = `year'
	}
	else {
		local week = 1
		rename `var' status_work_`year'_`week'
		local year0 = `year'
	}

}

drop sample_id_1979 sex

save "$rawpath\000_NLSY79_week_workstatus.dta", replace



